#include <bits/stdc++.h>
// 2025/03/31
// tag:
// Author: Zhang Muen
using namespace std;
class State {
public:
    int64_t id, weight;
    State(int64_t i, int64_t w)
    {
        id = i;
        weight = w;
    }
};

struct cmp {
    bool operator()(State& a, State& b)
    {
        return a.weight > b.weight;
    }
};

int64_t h, x, y, z, dist[100001];
vector<State> graph[100001];

void Dijkstra(int64_t start)
{
    for (int i = 0; i < x; i++)
        dist[i] = INT64_MAX;
    priority_queue<State, vector<State>, cmp> pq;
    dist[start] = 0;
    pq.push(State(start, 0));
    while (!pq.empty()) {
        State state = pq.top();
        pq.pop();
        int64_t Dist = state.weight;
        if (Dist > dist[state.id])
            continue;

        for (auto neighbor : graph[state.id]) {
            int64_t Dist2 = Dist + neighbor.weight;
            if (dist[neighbor.id] > Dist2) {
                dist[neighbor.id] = Dist2;
                pq.push(State(neighbor.id, Dist2));
            }
        }
    }
}

signed main()
{
    cin >> h >> x >> y >> z;
    h--;
    for (int i = 0; i < x; i++) {
        graph[i].push_back(State((i + y) % x, y));
        graph[i].push_back(State((i + z) % x, z));
    }
    Dijkstra(0);
    int64_t ans = 0;
    for (int i = 0; i < x; i++)
        if (h >= dist[i])
            ans += (h - dist[i]) / x + 1;
    cout << ans << endl;
    return 0;
}